package com.mgface.framework.AIOServer;

import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.AsynchronousSocketChannel;
import java.util.logging.Logger;

public class AIOClient {
	private static Logger log = Logger.getLogger(AIOClient.class.getSimpleName());

	public static void main(String[] args) throws Exception {
		AsynchronousSocketChannel client = AsynchronousSocketChannel.open();
		client.connect(new InetSocketAddress("127.0.0.1", 8888)).get();//等待连接建立成功
		client.write(ByteBuffer.wrap("你好".getBytes()));
		byte[] bytes = new byte[1024];
		client.read(ByteBuffer.wrap(bytes)).get();
		log.info(() -> "返回值:" + new String(bytes));
	}
}
